package com.ask.mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class ListMq {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    // 发送消息
    public void sendMessage(String key, String message) {
        stringRedisTemplate.opsForList().rightPush(key, message);
    }

    // 拿去消息
    public String receiveMessage(String key) {
        return stringRedisTemplate.opsForList().leftPop(key);
    }
}
